<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
   <h2> <span id="content"></span></h2>
    <button id="switch">暂停</button>

    <script>



        let w =new Worker('./year_data_time.js');
        w.onmessage = function (event) {
            document.getElementById('content').textContent = event.data;
        }

        document.getElementById('switch').onclick = function () {

            if(document.getElementById('switch').textContent =="开始") {
                w =new Worker('./year_data_time.js');
                document.getElementById('switch').textContent ="暂停";
                w.onmessage = function (event) {
                    document.getElementById('content').textContent = event.data;
                }
            }
            else {
                w.terminate();
                w.terminate();
                document.getElementById('switch').textContent ="开始";
            }
        }

    </script>


</body>
</html>